import Store from 'store'
import { originData } from './Global'

const STORAGE_KEY_PREFIX = 'STORAGE_KEY_LIVE_PC_STORAGE_'

class _Storage {
  getKey(key) {
    const data = originData['live'] || originData['replay']
    return STORAGE_KEY_PREFIX + 'ROOM_ID_' + data.info.id + 'USER_ID_' + data.user.id + '_' + key
  }
  save(_key, data) {
    const key = this.getKey(_key)
    Store.set(key, data)
  }
  read(_key) {
    const key = this.getKey(_key)
    const data = Store.get(key)
    return data
  }
  remove(_key) {
    const key = this.getKey(_key)
    Store.remove(key)
  }
  removeAll() {
    Store.clearAll()
  }
}
const Keys = {
  QA_VOICE_KEY: 'QA_VOICE_KEY',
  REPLAY_QA_VOICE_KEY: 'REPLAY_QA_VOICE_KEY'
}

const Storage = new _Storage()

module.exports = {
  Storage: Storage,
  Keys: Keys
}

